cmake_minimum_required(VERSION 3.20)
set(PROJ_NAME case17)
project(${PROJ_NAME})

set(HEADER_FILES
    D3D12HelloTriangle.h
    d3dx12.h
    DXSample.h
    DXSampleHelper.h
    stdafx.h
    Win32Application.h
    )
source_group("Header Files" FILES ${HEADER_FILES})

set(SOURCE_FILES
    D3D12HelloTriangle.cpp
    DXSample.cpp
    Main.cpp
    stdafx.cpp
    Win32Application.cpp
    )
source_group("Source Files" FILES ${SOURCE_FILES})

set(SHADER_FILES
    shaders.hlsl
    mipmaps.hlsl
    )
source_group("Assets/Shaders" FILES ${SHADER_FILES})
set_source_files_properties(${SHADER_FILES} PROPERTIES HEADER_FILE_ONLY ON)

# imgui files

set(IMGUI_LIB_FILES
    imgui/imconfig.h
    imgui/imgui.cpp
    imgui/imgui.h
    imgui/imgui_demo.cpp
    imgui/imgui_draw.cpp
    imgui/imgui_internal.h
    imgui/imgui_tables.cpp
    imgui/imgui_widgets.cpp
    imgui/imstb_rectpack.h
    imgui/imstb_textedit.h
    imgui/imstb_truetype.h
    imgui/misc/debuggers/imgui.natvis
    imgui/misc/debuggers/imgui.natstepfilter
    )
source_group("imgui" FILES ${IMGUI_LIB_FILES})

set(IMGUI_SRC_HEADER_FILES
    imgui/backends/imgui_impl_dx12.h
    imgui/backends/imgui_impl_win32.h
    )
source_group("Header Files/imgui" FILES ${IMGUI_SRC_HEADER_FILES})

set(IMGUI_SRC_SOURCE_FILES
    imgui/backends/imgui_impl_dx12.cpp
    imgui/backends/imgui_impl_win32.cpp
    )
source_group("Source Files/imgui" FILES ${IMGUI_SRC_SOURCE_FILES})

add_executable(${PROJ_NAME}
    ${HEADER_FILES}
    ${SOURCE_FILES}
    ${SHADER_FILES}
    ${IMGUI_LIB_FILES}
    ${IMGUI_SRC_HEADER_FILES}
    ${IMGUI_SRC_SOURCE_FILES}
    main.natstepfilter
    )

target_compile_definitions(${PROJ_NAME} PRIVATE
    _UNICODE
    UNICODE
    )

target_include_directories(${PROJ_NAME} PRIVATE
    imgui
    imgui/backends
    )

target_link_libraries(${PROJ_NAME}
    d3d12.lib
    dxgi.lib
    d3dcompiler.lib
    dxguid.lib
    dxcompiler.lib
    )

target_link_options(${PROJ_NAME} PRIVATE "/SUBSYSTEM:WINDOWS")

add_custom_command(TARGET ${PROJ_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/shaders.hlsl" "$<TARGET_FILE_DIR:${PROJ_NAME}>/shaders.hlsl"
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/mipmaps.hlsl" "$<TARGET_FILE_DIR:${PROJ_NAME}>/mipmaps.hlsl"
    )
